<?php

/**
 * paciente actions.
 *
 * @package    gestdent
 * @subpackage paciente
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class buscarpaciente2Actions extends sfActions
{

  var $var_doctor;
  var $var_hora;
    
  public function executeIndex(sfWebRequest $request)
  {
    $this->filtro = new GestdentPacienteFormFilter();
    $this->getUser()->setVarDoctorReserva($request->getParameter('VarDoctorReserva'));
    $this->getUser()->setVarHoraReserva($request->getParameter('VarHoraReserva'));
    $this->setTemplate('index');   
  }

  public function executeFiltrar(sfWebRequest $request)
  {
    $this->filtro = new GestdentPacienteFormFilter();
    $criteria = $this->filtro->buildCriteria($request->getParameter('gestdent_paciente_filters'));
    $this->gestdent_paciente_list = GestdentPacientePeer::doSelect($criteria);
    $this->setTemplate('filtrar');
  }

  public function executeShow(sfWebRequest $request)
  {
    //MUESTRA PACIENTE Y GUARDA ID
    $this->gestdent_paciente = GestdentPacientePeer::retrieveByPk($request->getParameter('id'));
    $this->getUser()->setVarPacienteReserva($request->getParameter('id'));

    //OBTIENE VALORES PARA EL COMBO DE ASISTENCIA
    $this->gestdent_tipoasistencia_list = GestdentTipoasistenciaPeer::doSelect(new Criteria());
    
    
    $this->VarFechaReserva  = $this->getUser()->getVarFechaReserva();
    $this->VarDoctorReserva = $this->getUser()->getVarDoctorReserva();
    $this->VarHoraReserva   = $this->getUser()->getVarHoraReserva();

    $this->formulario666 = new GestdentReservaForm1();

    //$this->forward404Unless($this->gestdent_paciente);
    //-----$this->gestdent_paciente = $this->getRoute()->getObject();
    //$this->getUser()->addPacienteToHistory($this->gestdent_paciente);
    //$this->getUser()->setSessionPaciente($this->gestdent_paciente);
  }

  public function executeGuardar(sfWebRequest $request)
  {

    $this->VarPacienteReserva  = $this->getUser()->getVarPacienteReserva();
    $this->VarFechaReserva     = $this->getUser()->getVarFechaReserva();
    $this->VarDoctorReserva    = $this->getUser()->getVarDoctorReserva();
    $this->VarHoraReserva      = $this->getUser()->getVarHoraReserva();

    $this->VarObservacionReserva   = $request->getParameter('Observacion-Reserva');
    $this->VarTipoAsistenciaReserva = $request->getParameter('TipoAsist-Reserva');

    //$this->VarTipoAsistenciaReserva = 2;

    $MyReserva = new GestdentReserva();

    $MyReserva->setHora($this->VarHoraReserva);
    $MyReserva->setFecha($this->VarFechaReserva);
    $MyReserva->setPaciente($this->VarPacienteReserva);
    $MyReserva->setPersonal($this->VarDoctorReserva);
    $MyReserva->setObservacion($this->VarObservacionReserva);
    $MyReserva->setTipoasistencia($this->VarTipoAsistenciaReserva);

    $MyReserva->save();

    $this->forward('atencionesvacio2', 'index');
   
  }



}
